package dao;

import hibernate.HibernateUtil;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import entity.Movimiento;

public class MovimientoDAO {

	private static MovimientoDAO instancia = null;
	private static SessionFactory sf = null;
	
	private MovimientoDAO(){
		sf = HibernateUtil.getSessionFactory();
	}
	
	public static MovimientoDAO getInstancia(){
		if(instancia == null)
			instancia = new MovimientoDAO();
		return instancia;
	}

	public void altaMovimiento(Movimiento m) {
		try{
			Session session = sf.openSession();
			session.beginTransaction();
			session.save(m);
			session.flush();
			session.getTransaction().commit();
			session.close();
		}catch(Exception e){
			System.out.println(e);
			System.out.println("ErrorDAO: Error al Insertar Movimiento");
		}
		
	}
	
}
